Skip to content

Conversation

@sergiocarracedo
Copy link
Collaborator

@sergiocarracedo sergiocarracedo commented Nov 19, 2025

Description

Add F0GridStack component, a wrapper over gridstask.js for react, with some specific features:

  • like the available sizes on resize.
  • API simplification
  • Allow to render react components easily
  • Add / Remove widgets API via ref
  • onChange event
  • metadata in widgets

Screenshots (if applicable)

Screen.Recording.2025-11-19.at.14.18.10.mov

Uploading Screen Recording 2025-11-20 at 09.15.26.mov…

Implementation details

@github-actions github-actions bot added the feat label Nov 19, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

🔍 Visual review for your branch is published 🔍

Here are the links to:

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Coverage Report for packages/react

Status Category Percentage Covered / Total
🔵 Lines 17.61% 18746 / 106422
🔵 Statements 17.61% 18746 / 106422
🔵 Functions 43.55% 886 / 2034
🔵 Branches 69.79% 2669 / 3824
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/components/exports.ts 0% 0% 0% 0% 1-18
packages/react/src/components/Utilities/F0GridStack/F0GridStack.tsx 54.79% 100% 0% 54.79% 90-94, 115-131, 135-149
packages/react/src/components/Utilities/F0GridStack/index.ts 0% 0% 0% 0% 1-8
packages/react/src/components/Utilities/F0GridStack/__stories__/GridStackReact.stories.tsx 0% 0% 0% 0% 1-227
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-context.ts 38.46% 100% 0% 38.46% 34-41
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-provider.tsx 0% 100% 100% 0% 7-180
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-render-context.ts 33.33% 100% 0% 33.33% 8-15
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-render-provider.tsx 10.25% 100% 0% 10.25% 20-104
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-render.tsx 0% 0% 0% 0% 1-27
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-widget-context.ts 0% 0% 0% 0% 1-18
packages/react/src/components/Utilities/F0GridStack/components/types.ts 100% 100% 100% 100%
Generated in workflow #9297 for commit 1bfb521 by the Vitest Coverage Report Action

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

size-limit report 📦

Path Size
JS: Stable 629.85 KB (+3.35% 🔺)
JS: Experimental 1016.3 KB (0%)
CSS 73.3 KB (+1.04% 🔺)

@sergiocarracedo sergiocarracedo marked this pull request as ready for review November 20, 2025 08:26
@sergiocarracedo sergiocarracedo requested a review from a team as a code owner November 20, 2025 08:26
Copilot AI review requested due to automatic review settings November 20, 2025 08:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the F0GridStack component, a React wrapper around the gridstack.js library that provides a draggable and resizable grid layout system. The implementation adds sophisticated features including constrained resizing with allowed sizes, simplified API, React component rendering support, imperative widget management via refs, layout change events, and widget metadata support.

Key Changes:

  • Added gridstack dependency (v12.3.3) to the project
  • Implemented F0GridStack component with comprehensive context providers for state management
  • Created extensive test coverage for both component behavior and render provider logic
  • Added Storybook documentation with interactive examples

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
pnpm-lock.yaml Added [email protected] dependency to lockfile
packages/react/package.json Added gridstack dependency to package.json
packages/react/src/components/Utilities/F0GridStack/index.ts Component export with experimental flag wrapper
packages/react/src/components/Utilities/F0GridStack/F0GridStack.tsx Main component implementing grid with resize constraints and ref API
packages/react/src/components/Utilities/F0GridStack/components/types.ts TypeScript module augmentation for gridstack types
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-context.ts Context definition for grid state and widget management API
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-provider.tsx Provider implementing grid initialization and event handling
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-render-provider.tsx Provider managing widget container mapping and grid lifecycle
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-render.tsx Component that portals React content into grid widget containers
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-render-context.ts Context for accessing widget container DOM elements
packages/react/src/components/Utilities/F0GridStack/components/grid-stack-widget-context.ts Context providing widget metadata to rendered components
packages/react/src/components/Utilities/F0GridStack/components/tests/grid-stack-render-provider.test.tsx Unit tests for WeakMap-based widget container management
packages/react/src/components/Utilities/F0GridStack/tests/F0GridStack.test.tsx Comprehensive test suite covering component rendering and resize logic
packages/react/src/components/Utilities/F0GridStack/stories/GridStackReact.stories.tsx Storybook examples demonstrating basic usage and ref methods
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +137 to +139
const element = document.body.querySelector<GridItemHTMLElement>(
`[gs-id="${id}"]`
)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using document.body.querySelector to find grid elements is fragile and could fail in complex DOM structures or SSR contexts. Consider using a ref to track elements or querying within a specific container scope instead of the entire document body.

Copilot uses AI. Check for mistakes.
Comment on lines +97 to +98
// ! gridStack is required to reinitialize the grid when the options change
[gridStack]
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "gridStack is required to reinitialize the grid when the options change" but gridStack shouldn't need to be in the dependency array since it's already handled by the parent component's re-render logic. This may cause unnecessary re-memoization.

Suggested change
// ! gridStack is required to reinitialize the grid when the options change
[gridStack]
// Dependency array intentionally left empty; parent re-render logic handles gridStack changes
[]

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +23
// Clear the WeakMap before each test
gridWidgetContainersMap.constructor.prototype.clear?.call(
gridWidgetContainersMap
)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling .clear() on WeakMap's prototype is incorrect - WeakMaps don't have a clear method. This test cleanup logic will fail silently. WeakMaps cannot be cleared programmatically; you need to let garbage collection handle cleanup or use a different data structure for testing.

Copilot uses AI. Check for mistakes.
Comment on lines +86 to +87
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [gridStack])
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The eslint-disable comment masks a missing onChange dependency. While excluding onChange might be intentional to avoid re-running the effect on every callback change, this should be documented or the callback should be stabilized via useCallback in the parent.

Copilot uses AI. Check for mistakes.
@sergiocarracedo sergiocarracedo merged commit c1e7853 into main Nov 20, 2025
21 checks passed
@sergiocarracedo sergiocarracedo deleted the feat/gridstack branch November 20, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants